### Partisanship Plots ###
filet <- paste("/users/brucedesmarais/Dropbox/Research/Active/Camp/Code/ClusteringCode/DescriptiveCode/Graphics/","pExt.pdf",sep="")
pdf(filet,width=5.5,height=3,family="Times", pointsize=14)
par(las=1,mar=c(3.5,5,.25,.25))
plot(1:10,1:10,xlim=c(0,100),ylim=c(50,105),ylab="% in One Party",type="n",xlab="")

for(t in seq(1994,2010,by=2)){

## Axioms
# 1. Poorly funded
# 2. Large Membership
# 3. Highly partisan
# 

clustFile <- paste("/users/brucedesmarais/Dropbox/Research/Active/Camp/Data/ClusterData/clusters",t,".csv",sep="")

clustDat <- read.csv(clustFile,stringsAsFactors=F)

pctInc <- 100*clustDat$incumbP[-which.max(clustDat$members)]
pctExt <- 100*abs(apply(cbind(clustDat$RepP[-which.max(clustDat$members)],1-clustDat$RepP[-which.max(clustDat$members)]),1,max))
#lines(lowess(cbind(pctInc,pctExt)[order(pctInc),],f=.5),lwd=2,col="grey60")
points(pctInc,pctExt,pch=1,col=ifelse(clustDat$RepP<.5,"blue","red"),cex=log(clustDat$members)/2.5)
#text(15,60,t,cex=1.25)

}
title(xlab="% Incumbents",line=2.25)
dev.off()

library(ggplot2)

### Size and Money ###
for(t in seq(1994,2010,by=2)){
clustFile <- paste("/users/brucedesmarais/Dropbox/Research/Active/Camp/Data/ClusterData/clusters",t,".csv",sep="")

clustDat <- read.csv(clustFile,stringsAsFactors=F)

fileS <- paste("/users/brucedesmarais/Dropbox/Research/Active/Camp/Code/ClusteringCode/DescriptiveCode/Graphics/","sz",t,".pdf",sep="")
fileA <- paste("/users/brucedesmarais/Dropbox/Research/Active/Camp/Code/ClusteringCode/DescriptiveCode/Graphics/","amt",t,".pdf",sep="")


xlabs <- c("0","500k","1m","1.5m","2m","2.5m")
xat <- c(0,500000,1000000,1500000,2000000,2500000)
pdf(fileA,width=4,height=1.1,family="Times", pointsize=14)
par(las=1,mar=c(2.5,2,.1,.65))
plot(1:10,1:10,xlim=c(0,2500000),ylim=c(50,100),ylab="",type="n",xlab="",yaxt="n",xaxt="n")
abline(v=clustDat$amount,col=ifelse(clustDat$amount==min(clustDat$amount),"red",rgb(0,0,0,125,maxColorValue=255)), lwd=2.25, lty = ifelse(clustDat$amount==min(clustDat$amount),2,1))

title(ylab=paste("'",substr(t,3,4),sep=""),line=1)
if(t==2010) axis(1,at=xat,lab=xlabs)

dev.off()

pdf(fileS,width=4,height=1.1,family="Times", pointsize=14)
par(las=1,mar=c(2.5,2,.1,.65))
plot(1:10,1:10,xlim=c(0,500),ylim=c(50,100),ylab="",type="n",xlab="",yaxt="n",xaxt=ifelse(t==2010,"s","n"))
abline(v=clustDat$members,col=ifelse(clustDat$members==max(clustDat$members),"red",rgb(0,0,0,125,maxColorValue=255)), lwd=2.25, lty = ifelse(clustDat$members==max(clustDat$members),2,1))
#title(ylab=substr(t,3,4),line=1)
title(ylab=paste("'",substr(t,3,4),sep=""),line=1)
dev.off()



}




